/**** Switch and EEPROM Functions  *****************************************************************
Switch 1 (right side) selects LED sequence in standalone mode
Switch 2 (left side) toggles standalone and I2C modes
Both switches are monitored using PC Interrupts and settings are saved to EEPROM on change.
***************************************************************************************************/      

// Switch1 ISR
void S1() {  
  if (Switch2_val==1) {
    Switch1_val++;
    S1Write();
  }
}

// Switch2 ISR
void S2() {
  Switch2_val++;
  if (Switch2_val==2)
    Switch1_val=0;
  else
    if (Switch2_val>2)  
      Switch2_val=0;
  S2Write();
}

// Read last Switch1 value on power up, if saved.
void eepromRead() { 
  uint8_t S1Status=EEPROM.read(0);
  if (S1Status==104)
    Switch1_val=EEPROM.read(1);
  else
    Switch1_val=0; // Default LED sequence if no saved value
  uint8_t S2Status=EEPROM.read(2);
  if (S2Status==105)
    Switch2_val=EEPROM.read(3);
  else
    Switch2_val=0; // Defaults to I2C mode if no saved value
}

// Save Switch1 status for next power up
void S1Write() { 
  EEPROM.write(0,104);
  EEPROM.write(1,Switch1_val);
}

// Save Switch2 status for next power up
void S2Write() { 
  EEPROM.write(2,105);
  EEPROM.write(3,Switch2_val);
}


